package org.marsdonne.auth;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.core.JmsTemplate;

import javax.annotation.Resource;

public class UserServImpl implements UserServ {
    @Value("${auth.artemis.channels.user.join.organization:channels.user.join.organization}")
    private String channel_binding;

    @Value("${auth.artemis.channels.user.leave.organization:channels.user.leave.organization}")
    private String channel_unbinding;

    @Resource(name = "authJmsTemplate")
    private JmsTemplate authJmsTemplate;

    @Override
    public void bind(OrganizationStaff organizationStaff) {
        authJmsTemplate.send(channel_binding, session -> session.createObjectMessage(organizationStaff));
    }

    @Override
    public void unbind(OrganizationStaff organizationStaff) {
        authJmsTemplate.send(channel_unbinding, session -> session.createObjectMessage(organizationStaff));
    }
}
